﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using AccessDAL;
using AccessModel;
using Utility;

namespace web.SerialNumber
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ShowErrorMsg(string errorMsg)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", " <script language=javascript>alert('" + errorMsg + "') </script>");
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            User user = UserDAL.UserLogin(this.txtUnm.Text.Trim().ToString(),MD5Class.getMd5Hash(this.txtPwd.Text.Trim().ToString()));
            if (user.id>0)
            {
                Session["user"] = user.uNm;
                Response.Redirect("index.aspx");
            }
            else
            {
                ShowErrorMsg("用户名或密码错误，请重试！");
            }
        }
        
    }
}
